package com.ultimatech.webappdemo.base.model;
// default package

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;


/**
 * User entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sys_user"
)

public class SysUser implements java.io.Serializable {


    // Fields    

    private Integer id;
    private String password;
    private String username;
    private Date createTime;
    private String avatarUrl;
    private String city;
    private Integer gender;
    private String nickName;
    private String openid;
    private String province;
    private Integer age;
    private String mobile;
    private Integer status;
    private Timestamp modifyTime;
    private Integer deleted;
    private String description;
    private SysGroup group;
    private String cellPhoneNo;

    private List<SysRole> roleList;//


    // Constructors

    /**
     * default constructor
     */
    public SysUser() {
    }

    /**
     * minimal constructor
     */
    public SysUser(String password, String username, Integer gender) {
        this.password = password;
        this.username = username;
        this.gender = gender;
    }


    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)

    @Column(name = "id", unique = true, nullable = false)

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }


    @Column(name = "password", nullable = false)

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "username", nullable = false)

    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }


    @Column(name = "createTime", length = 0)

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Column(name = "avatarUrl")

    public String getAvatarUrl() {
        return this.avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    @Column(name = "city")

    public String getCity() {
        return this.city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Column(name = "gender", nullable = false)

    public Integer getGender() {
        return this.gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    @Column(name = "nickName")

    public String getNickName() {
        return this.nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Column(name = "openid")

    public String getOpenid() {
        return this.openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    @Column(name = "province")

    public String getProvince() {
        return this.province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    @Column(name = "age")

    public Integer getAge() {
        return this.age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Column(name = "mobile")

    public String getMobile() {
        return this.mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    @Column(name = "status")

    public Integer getStatus() {
        return this.status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Column(name = "modifyTime", length = 0)

    public Timestamp getModifyTime() {
        return this.modifyTime;
    }

    public void setModifyTime(Timestamp modifyTime) {
        this.modifyTime = modifyTime;
    }

    @Column(name = "deleted")

    public Integer getDeleted() {
        return this.deleted;
    }

    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    @Column(name = "description")

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_user_role", joinColumns = {@JoinColumn(name = "user_id")}, inverseJoinColumns = {@JoinColumn(name = "role_id")})
    public List<SysRole> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<SysRole> roleList) {
        this.roleList = roleList;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public SysGroup getGroup() {
        return group;
    }

    public void setGroup(SysGroup group) {
        this.group = group;
    }

    @Transient
    public Set<String> getRolesName() {
        Set<String> set = new HashSet<String>();
        for (SysRole role : this.roleList) {
            set.add(role.getRolename());
        }
        return set;
    }

    public String getCellPhoneNo() {
        return cellPhoneNo;
    }

    public void setCellPhoneNo(String cellPhoneNo) {
        this.cellPhoneNo = cellPhoneNo;
    }
}
   








